package ui;

import java.awt.Color;
import java.awt.Component;
import java.awt.SystemColor;

import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;

@SuppressWarnings("serial")
public class ArticuloRender extends DefaultTableCellRenderer {

	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, 
			boolean hasFocus, int row, int column) {
			
		JLabel cell = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, false, 
				row, column);
				
		if(row%2 == 0) {
			cell.setBackground(SystemColor.window);
		}
		else
			cell.setBackground(SystemColor.control);
		
		if(isSelected) {
			cell.setBackground(SystemColor.scrollbar);				
		}
		
		if(column == 5) {
			cell.setHorizontalAlignment(SwingConstants.RIGHT);
		} else {
			if(column == 4 || column == 6) {
				cell.setHorizontalAlignment(SwingConstants.CENTER);
			} else {
				cell.setHorizontalAlignment(SwingConstants.LEFT);
			}
		}
		
		if(column == 6) {
			cell.setForeground(Color.BLUE);
		} else {
			cell.setForeground(Color.black);
		}
		
		return cell;
	}
}